package com.xyzwps.server.paimon.infra

import org.slf4j.LoggerFactory
import org.springframework.core.env.Environment
import org.springframework.stereotype.Service

internal val log = LoggerFactory.getLogger(InfoService::class.java)

@Service
class InfoService(private val environment: Environment) {

    private fun isDev(): Boolean {
        val activeProfiles = environment.activeProfiles
        for (profile in activeProfiles) {
            if ("dev" == profile) {
                return true
            }
        }
        return false
    }

    fun logging() {
        if (!isDev()) {
            return
        }

        val port = environment.getProperty("server.port")
        val swaggerUiPath = environment.getProperty("springdoc.swagger-ui.path")
        val graphiqlPath = environment.getProperty("spring.graphql.graphiql.path")

        log.info("Actuator:   http://localhost:{}/actuator", port)
        log.info("GraphiQL:   http://localhost:{}{}", port, graphiqlPath)
        log.info("Swagger UI: http://localhost:{}{}", port, swaggerUiPath)
    }
}
